/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package physical_spaces.beans;

import Entity.ControlFile;
import java.io.Serializable;
import java.sql.Connection;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import login.beans.ConectionBean;
import physical_spaces.business.ControlFileDataModel;
import physical_spaces.business.ListControlFileBusiness;

/**
 *
 * @author JuanSebastian
 */
@ManagedBean
@ViewScoped
public class ListControlFilesBean implements Serializable {
    
    private List<ControlFile> controlFiles;
    private ControlFileDataModel mediumControlFileModel;
    private static final long serialVersionUID = 308L;
    private ControlFile selectedControlFile;   
    private ListControlFileBusiness listControlFileBusiness;
    private Connection conn;
    
    
    public ListControlFilesBean() {
        FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
        HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
        ConectionBean conectionBean =(ConectionBean) session.getAttribute("conectionBean");        
        this.conn = conectionBean.currentConnection;
        listControlFileBusiness = new ListControlFileBusiness(conn);
        controlFiles=listControlFileBusiness.listControlFiles();
        mediumControlFileModel = new ControlFileDataModel(controlFiles);
              
    }

    public List<ControlFile> getControlFiles() {
        return controlFiles;
    }

    public void setControlFiles(List<ControlFile> controlFiles) {
        this.controlFiles = controlFiles;
    }

    public ControlFileDataModel getMediumControlFileModel() {
        return mediumControlFileModel;
    }

    public void setMediumControlFileModel(ControlFileDataModel mediumControlFileModel) {
        this.mediumControlFileModel = mediumControlFileModel;
    }

    public ControlFile getSelectedControlFile() {
        return selectedControlFile;
    }

    public void setSelectedControlFile(ControlFile selectedControlFile) {
        this.selectedControlFile = selectedControlFile;
    }

    public ListControlFileBusiness getListControlFileBusiness() {
        return listControlFileBusiness;
    }

    public void setListControlFileBusiness(ListControlFileBusiness listControlFileBusiness) {
        this.listControlFileBusiness = listControlFileBusiness;
    }

    public Connection getConn() {
        return conn;
    }

    public void setConn(Connection conn) {
        this.conn = conn;
    }
    
    
}
